package problems;

import java.math.BigInteger;

public class Euler073 extends AbstractEuler {

	@Override
	public Number calculate() {
		int answer = 0;
		
		for (int d = 12000; d > 2; d--) { //no need to do d == 2, because the only fraction with it is 1/2 and it is not in the required range
			for (int n = d / 2; n > d / 3; n--) { //everything between 1/2 and 1/3
				BigInteger greatestCommonDivisor = BigInteger.valueOf(d).gcd(BigInteger.valueOf(n));
				if (greatestCommonDivisor.equals(BigInteger.ONE)) {
					answer++;
				}
				//if GCD != 1, then it is not a reduced proper fraction. We'll count it in a later loop.
			}
		}

		return answer;
	}

	@Override
	protected Number getCorrectAnswer() {
		return 7295372;
	}

}
